package cn.bdqn.t354.dao;

import cn.bdqn.t354.entity.Role;
import cn.bdqn.t354.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@SpringBootTest
@RunWith(SpringRunner.class)
public class ManyToOneTester {
    @Resource
    UserDao userDao;


    @Test
    public void test(){
        User user = userDao.findById(6l).get();
        System.out.println(user.getUsrName());

        //对象导航查询 通过用户能够查询到角色
        Role role = user.getRole();
        System.out.println(role.getRoleName());
    }
}
